package com.test.daily.leetcode.y2021.m11.day1106;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @descriptions: Code01_LostNumber
 * @author: Tom
 * @date: 2021/11/6 上午 08:37
 * @version: 1.0
 */
public class Code01_LostNumber01 {
    // 丟失的數字
    public int missingNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i <= nums.length; i++){
            set.add(i);
        }
        for(int element: nums){
            set.remove(element);
        }
        Iterator<Integer> ite = set.iterator();
        return ite.next();
    }
}
